/**
 */
package de.thwildau.tm.moses.asn1.asn1.impl;

import de.thwildau.tm.moses.asn1.asn1.Asn1Package;
import de.thwildau.tm.moses.asn1.asn1.Constraint;
import de.thwildau.tm.moses.asn1.asn1.ConstraintSpec;
import de.thwildau.tm.moses.asn1.asn1.ExceptionSpec;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Constraint</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ConstraintImpl#getConstraintSpec <em>Constraint Spec</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ConstraintImpl#getExceptionSpec <em>Exception Spec</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ConstraintImpl extends MinimalEObjectImpl.Container implements Constraint
{
  /**
   * The cached value of the '{@link #getConstraintSpec() <em>Constraint Spec</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getConstraintSpec()
   * @generated
   * @ordered
   */
  protected ConstraintSpec constraintSpec;

  /**
   * The cached value of the '{@link #getExceptionSpec() <em>Exception Spec</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExceptionSpec()
   * @generated
   * @ordered
   */
  protected ExceptionSpec exceptionSpec;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ConstraintImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Asn1Package.Literals.CONSTRAINT;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ConstraintSpec getConstraintSpec()
  {
    return constraintSpec;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetConstraintSpec(ConstraintSpec newConstraintSpec, NotificationChain msgs)
  {
    ConstraintSpec oldConstraintSpec = constraintSpec;
    constraintSpec = newConstraintSpec;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.CONSTRAINT__CONSTRAINT_SPEC, oldConstraintSpec, newConstraintSpec);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setConstraintSpec(ConstraintSpec newConstraintSpec)
  {
    if (newConstraintSpec != constraintSpec)
    {
      NotificationChain msgs = null;
      if (constraintSpec != null)
        msgs = ((InternalEObject)constraintSpec).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.CONSTRAINT__CONSTRAINT_SPEC, null, msgs);
      if (newConstraintSpec != null)
        msgs = ((InternalEObject)newConstraintSpec).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.CONSTRAINT__CONSTRAINT_SPEC, null, msgs);
      msgs = basicSetConstraintSpec(newConstraintSpec, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.CONSTRAINT__CONSTRAINT_SPEC, newConstraintSpec, newConstraintSpec));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ExceptionSpec getExceptionSpec()
  {
    return exceptionSpec;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetExceptionSpec(ExceptionSpec newExceptionSpec, NotificationChain msgs)
  {
    ExceptionSpec oldExceptionSpec = exceptionSpec;
    exceptionSpec = newExceptionSpec;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.CONSTRAINT__EXCEPTION_SPEC, oldExceptionSpec, newExceptionSpec);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setExceptionSpec(ExceptionSpec newExceptionSpec)
  {
    if (newExceptionSpec != exceptionSpec)
    {
      NotificationChain msgs = null;
      if (exceptionSpec != null)
        msgs = ((InternalEObject)exceptionSpec).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.CONSTRAINT__EXCEPTION_SPEC, null, msgs);
      if (newExceptionSpec != null)
        msgs = ((InternalEObject)newExceptionSpec).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.CONSTRAINT__EXCEPTION_SPEC, null, msgs);
      msgs = basicSetExceptionSpec(newExceptionSpec, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.CONSTRAINT__EXCEPTION_SPEC, newExceptionSpec, newExceptionSpec));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Asn1Package.CONSTRAINT__CONSTRAINT_SPEC:
        return basicSetConstraintSpec(null, msgs);
      case Asn1Package.CONSTRAINT__EXCEPTION_SPEC:
        return basicSetExceptionSpec(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Asn1Package.CONSTRAINT__CONSTRAINT_SPEC:
        return getConstraintSpec();
      case Asn1Package.CONSTRAINT__EXCEPTION_SPEC:
        return getExceptionSpec();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Asn1Package.CONSTRAINT__CONSTRAINT_SPEC:
        setConstraintSpec((ConstraintSpec)newValue);
        return;
      case Asn1Package.CONSTRAINT__EXCEPTION_SPEC:
        setExceptionSpec((ExceptionSpec)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.CONSTRAINT__CONSTRAINT_SPEC:
        setConstraintSpec((ConstraintSpec)null);
        return;
      case Asn1Package.CONSTRAINT__EXCEPTION_SPEC:
        setExceptionSpec((ExceptionSpec)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.CONSTRAINT__CONSTRAINT_SPEC:
        return constraintSpec != null;
      case Asn1Package.CONSTRAINT__EXCEPTION_SPEC:
        return exceptionSpec != null;
    }
    return super.eIsSet(featureID);
  }

} //ConstraintImpl
